package com.gwcm.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gwcm.model.dto.role.RoleQueryRequest;
import com.gwcm.model.entity.Role;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gwcm.model.vo.RoleVo;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
* @author 15375
* @description 针对表【role(角色表)】的数据库操作Mapper
* @createDate 2023-03-21 16:40:11
* @Entity com.gwcm.model.entity.Role
*/
public interface RoleMapper extends BaseMapper<Role> {
    List<Role> getRolesByUserId(@Param("userId")Long userId);
    /**
     * 根据用户id关联角色
     * @param roleId
     * @param userId
     * @return
     */
    int attachRoleByUserId(@Param("roleId") Long roleId, @Param("userId")Long userId);

    /**
     * 根据id查询role
     * @param id
     * @return
     */
    Role selectRoleById(Long id);

    /**
     * 根据user表id查找role列表
     * @param userId
     * @return
     */
    List<Role> selectRolesByUserId(Long userId);

    /**
     * 根据username查询role列表
     * @param username
     * @return
     */
    List<Role> selectRolesByUsername(String username);

    /**
     * 根据user表id查询role表的id列表
     * @param userId
     * @return
     */
    List<Long> selectRoleIdListByUserId(Long userId);

    /**
     * 查询role列表
     * @param role
     * @return
     */
    List<Role> selectRoleList(Role role);

    /**
     * 删除角色
     * @param roleId
     * @return
     */
    int deleteRoleById(Long roleId);

    /**
     * 批量删除角色信息
     * @param roleIds
     * @return
     */
    int deleteRoleByIds(Long[] roleIds);

    Role checkRoleKeyUnique(String roleKey);

    IPage<RoleVo> selectRoleToPage(IPage<Role> page, @Param("roleQueryRequest") RoleQueryRequest roleQueryRequest);
}




